# -*- coding: utf-8 -*-
# @Time : 2024/2/27 17:05
# @Author : ZH
# @File : 71.py
# @Software: PyCharm
class Solution(object):
    def simplifyPath(self, path):
        """
        :type path: str
        :rtype: str
        """
        # /a/./b/../../c/
        path = [i for i in path.split('/') if i != '' and i != '.']
        z = []
        for index, value in enumerate(path):
            if value == '..':
                if z:
                    z.pop()
            else:
                z.append(value)
        return '/' + '/'.join(z)


if __name__ == '__main__':
    so = Solution()
    so.simplifyPath('/a/./b/../../c/')
